package com.yxw.yxnet_cd_center.customer_service.service.impl;



//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yxw.yxnet_cd_center.customer_service.entity.YxcscBaseChannelUserEntity;
import com.yxw.yxnet_cd_center.customer_service.dto.YxcscBaseChannelUserDTO;
import com.yxw.yxnet_cd_center.customer_service.mapper.YxcscBaseChannelUserMapper;
import com.yxw.yxnet_cd_center.customer_service.service.IYxcscBaseChannelUserService;



@Service
//public class YxcscBaseChannelUserServiceImpl  extends ServiceImpl<YxcscBaseChannelUserMapper, YxcscBaseChannelUserEntity> implements IYxcscBaseChannelUserService{
public class YxcscBaseChannelUserServiceImpl  implements IYxcscBaseChannelUserService{
    @Autowired
    private YxcscBaseChannelUserMapper oYxcscBaseChannelUserMapper;

    /*** 
    * 根据id查找
    * @param id
    * @return YxcscBaseChannelUserEntity
    **/
    @Override
    public YxcscBaseChannelUserEntity selectById(Integer id)
    {
        if(ObjectUtil.isEmpty(id))
        {
            return null;
        }
        return oYxcscBaseChannelUserMapper.selectById(id);
    }
    /*** 
    * 自定义查询
    * @param oYxcscBaseChannelUserDTO
    * @return List<YxcscBaseChannelUserEntity>
    **/
    @Override
    public List<YxcscBaseChannelUserEntity> selectList(YxcscBaseChannelUserDTO oYxcscBaseChannelUserDTO)
    {
        YxcscBaseChannelUserEntity oYxcscBaseChannelUserEntity = new YxcscBaseChannelUserEntity();
        BeanUtil.copyProperties(oYxcscBaseChannelUserDTO, oYxcscBaseChannelUserEntity);
        QueryWrapper<YxcscBaseChannelUserEntity> oYxcscBaseChannelUserQueryWrapper = new QueryWrapper();
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getId()),"id",oYxcscBaseChannelUserEntity.getId());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getChannelCode()),"channel_code",oYxcscBaseChannelUserEntity.getChannelCode());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getUserId()),"user_id",oYxcscBaseChannelUserEntity.getUserId());
        //List<YxcscBaseChannelUserEntity> oListYxcscBaseChannelUser = oYxcscBaseChannelUserMapper.selectList(oYxcscBaseChannelUserQueryWrapper);
        //return Res.ok(oListYxcscBaseChannelUser);
        return  oYxcscBaseChannelUserMapper.selectList(oYxcscBaseChannelUserQueryWrapper);
    }
    /*** 
    * 自定义统计
    * @param oYxcscBaseChannelUserEntity
    * @return Integer
    **/
    @Override
    public Integer selectCount(YxcscBaseChannelUserDTO oYxcscBaseChannelUserDTO)
    {
         YxcscBaseChannelUserEntity oYxcscBaseChannelUserEntity = new YxcscBaseChannelUserEntity();
        BeanUtil.copyProperties(oYxcscBaseChannelUserDTO, oYxcscBaseChannelUserEntity);
        QueryWrapper<YxcscBaseChannelUserEntity> oYxcscBaseChannelUserQueryWrapper = new QueryWrapper();
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getId()),"id",oYxcscBaseChannelUserEntity.getId());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getChannelCode()),"channel_code",oYxcscBaseChannelUserEntity.getChannelCode());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getUserId()),"user_id",oYxcscBaseChannelUserEntity.getUserId());
        return oYxcscBaseChannelUserMapper.selectCount(oYxcscBaseChannelUserQueryWrapper);
    }
    /*** 
    * 自定义分页查询
    * @param currentPage 当前页
    * @param pageSize 分页大小
    * @param oYxcscBaseChannelUserEntity
    * @return Page
    **/
    @Override
    public Page selectPage(int currentPage,int pageSize,YxcscBaseChannelUserDTO oYxcscBaseChannelUserDTO)
    {
        YxcscBaseChannelUserEntity oYxcscBaseChannelUserEntity = new YxcscBaseChannelUserEntity();
        BeanUtil.copyProperties(oYxcscBaseChannelUserDTO, oYxcscBaseChannelUserEntity);
        Page<YxcscBaseChannelUserEntity> pageParams = new Page<>(currentPage,pageSize);
        QueryWrapper<YxcscBaseChannelUserEntity> oYxcscBaseChannelUserQueryWrapper = new QueryWrapper();
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getId()),"id",oYxcscBaseChannelUserEntity.getId());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getChannelCode()),"channel_code",oYxcscBaseChannelUserEntity.getChannelCode());
        oYxcscBaseChannelUserQueryWrapper.eq(ObjectUtil.isNotEmpty(oYxcscBaseChannelUserEntity.getUserId()),"user_id",oYxcscBaseChannelUserEntity.getUserId());
        return oYxcscBaseChannelUserMapper.selectPage(pageParams, oYxcscBaseChannelUserQueryWrapper);
    }
}
    

